package com.zhiwei.msf.app.service.impl;

import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.springframework.stereotype.Service;

import com.zhiwei.msf.app.service.GitCredentialService;

/**
 * function author zhiwei.yang 
 * time 2020-3-4-11:00
 */
@Service
public class GitCredentialServiceImpl implements GitCredentialService {

	@Override
	public CredentialsProvider createCredential(String username, String password) {
		if (org.apache.commons.lang3.StringUtils.isEmpty(username)
				|| org.apache.commons.lang3.StringUtils.isEmpty(password)) {
			return null;
		}
		return new UsernamePasswordCredentialsProvider(username, password);
	}
}